package outputter;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import common.Constant;

public class WriteResult {
	public static void writefile(ArrayList<String> lstValue){
		File file = new File(Constant.RESULT_FOLDER);
		if (!file.exists()) {
			file.mkdirs();
		}
		Date timeNow = new Date(System.currentTimeMillis());
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_hhmmss");
		String subString = sdf.format(timeNow);
		String fileName = "result_" + subString + ".txt";
		file = new File(Constant.RESULT_FOLDER + File.separator + fileName);
		BufferedWriter bw;
		try {
			bw = new BufferedWriter(new FileWriter(file));
			for (int i = 0; i < lstValue.size(); i++) {
				String value = lstValue.get(i);
				if (i != 0)
					bw.newLine();
				bw.write(value);
			}
			bw.flush();
			bw.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
